package net.lzzy.practices.entities;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Chapter类代表一个课程章节实体，继承自BaseEntity以获取基本的实体功能。
 * 该类负责存储章节的详细信息，如名称、描述、开放状态、创建和更新时间，
 * 并维护与Course（课程）和Question（问题）实体的关系。
 */
@Entity
@Getter
@Setter
public class Chapter extends BaseEntity{
    private String name;

    private String description;

    private boolean open;

    private Date createTime;

    private Date updateTime;

    @ManyToOne
    private Course course;

    @OneToMany(mappedBy = "chapter")
    private List<Question> questions;

    public Chapter() {
        createTime = new Date();
        updateTime = new Date();
    }
}
